#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#Author: alvayang <alvayang@tabex.org>
#Last Change: 
#Description: 
import sqlite3
import os, sys

MAX_DB_CONNECT_TIMEOUT = 10
SCHEMA_NAME = 'msg.schema.sql'
DB_NAME = 'db/msg.sqlite3'
__path__ = os.path.dirname(os.path.abspath(__file__))
SCHEMA = ''.join([x.split('--', 1)[0].strip() for x in \
    file(os.path.join(__path__,'db',  SCHEMA_NAME))]).strip()
db = sqlite3.connect(DB_NAME, MAX_DB_CONNECT_TIMEOUT)
db.isolation_level = 'EXCLUSIVE'
db.executescript(SCHEMA)
db.commit()

